package com.sgcc.pda.frme.protocol.ws.sendbean;


import com.sgcc.pda.frme.protocol.ws.DataConvert;

/**
 * 获取电表误差数据（请求帧的数据域内容）
 * Created by guorongxin on 2017/2/10.
 */

public class MeterErrorParams {

    /**
     * 被测表计地址（BCD，6字节）
     */
    private String testMeterAddress;

    /**
     * 脉冲记数次数（BCD，1字节）
     */
    private String pulseNum;

    public String getTestMeterAddress() {
        return testMeterAddress;
    }

    public void setTestMeterAddress(String testMeterAddress) {
        this.testMeterAddress = testMeterAddress;
    }

    public String getPulseNum() {
        return pulseNum;
    }

    public void setPulseNum(String pulseNum) {
        this.pulseNum = pulseNum;
    }

    /**
     * 将请求数据转化为byte数组
     *
     * @return 请求数据
     */
    public byte[] fromBytes() {
        return DataConvert.toBytes(toString());
    }


    /**
     * 将请求数据转化为字符串
     *
     * @return 请求数据
     */
    public String toString() {
        StringBuffer result = new StringBuffer();
        if (null == testMeterAddress || testMeterAddress.length() != 12) {
            return null;
        }
        result.append(testMeterAddress);
        if (null == pulseNum || pulseNum.length() != 2) {
            return null;
        }
        //此数不大于16
        result.append(pulseNum);

        return result.toString();
    }
}
